#ifndef RECEIVER_THREAD_H
#define RECEIVER_THREAD_H

#include <boost/shared_ptr.hpp>
#include <expat.h>

#include "title.h"
#include "worker_thread.h"
#include "play_message.h"
#include "queue.h"
#include "socket/socket.h"
#include "socket/blocking_policy.h"
#include "socket/throwing_error_policy.h"
#include "socket/no_locking_policy.h"

#define BUFF_SIZE 10240


typedef network::socket<network::blocking_policy, 
			network::no_locking_policy,
			network::throwing_error_policy> my_socket;

class receiver_thread : public worker_thread {
public:
	receiver_thread(boost::shared_ptr<my_socket> sock,
			boost::shared_ptr<queue> q)
	:worker_thread(), _sock(sock), _queue(q) {}
	virtual ~receiver_thread() { interrupt(); _thrd.reset(); }
	virtual void run();
	virtual void start();
	void dispatch(const string &tag, const list<string> &attr);
private:
	boost::shared_ptr<boost::thread> _thrd;
	boost::shared_ptr<my_socket> _sock;
	boost::shared_ptr<queue> _queue;
	XML_Parser _parser;
};

#endif
